package com.onesports.intelligent.k12.polarlight.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.baomidou.mybatisplus.annotation.IEnum;
import com.fasterxml.jackson.annotation.JsonValue;
import com.onesports.framework.kit.common.util.ParamUtils;
import com.onesports.intelligent.k12.polarlight.annotation.SysDict;

/**
 * 订单状态枚举类
 *
 * @author Wu
 * */
@SysDict(value = "订单状态",code = "OrderStatus")
public enum OrderStatusEnum implements IEnum<String> {

    /**
     * 订单状态枚举类
     */
    WAIT("1","待付款"),
    ALREADY("2","已付款"),
    REFUNDING("3","退款中"),
    WAIT_REFUND("4","已退款"),
    CANCEL("5","已取消"),
    ;

  //  @EnumValue
    private String value;

    private String label;

    OrderStatusEnum(String value, String label) {
        this.value = value;
        this.label = label;
    }

    @Override
    public String getValue() {
        return value;
    }
    @JsonValue
    public String getLabel() {
        return this.label;
    }



    public static OrderStatusEnum of(String desc) {
        for (OrderStatusEnum status : OrderStatusEnum.values()) {
            if (ParamUtils.equals(status.label, desc)) {
                return status;
            }
        }
        return null;
    }

    public static OrderStatusEnum typeOf(String type) {
        if(OrderStatusEnum.WAIT.getValue().equals(type)){
            return OrderStatusEnum.WAIT;
        }else  if(OrderStatusEnum.ALREADY.getValue().equals(type)){
            return OrderStatusEnum.ALREADY;
        }else if(OrderStatusEnum.CANCEL.getValue().equals(type)){
            return OrderStatusEnum.CANCEL;
        }

        return null;
    }
}
